package com.dpf.hou.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dpf.hou.pojo.Adoption;
import com.dpf.hou.pojo.User;
import com.dpf.hou.service.AdoptionService;
import com.dpf.hou.util.RefuseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("adoption")
public class AdoptionController {
    @Autowired
    private AdoptionService adoptionService;


    @GetMapping("getPageByName")
    public Page<Adoption> getPageByName(int page, int size, String username){
        Page<Adoption> res=adoptionService.getPageByName(page,size,username);
        return res;
    }

    @PostMapping("petApply")
    public boolean petApply(int userid,int petid,String note){

        return adoptionService.petApply(userid,petid,note);
    }

    @GetMapping("adoGet")
    public Page<Adoption> adoGet(int page,int size){
        Page<Adoption> res=adoptionService.adoGet(page,size);
        return res;
    }
    @GetMapping("adoRecordGet")
    public Page<Adoption> adoRecordGet(int page,int size,int userid){
        Page<Adoption> res=adoptionService.adoRecordGet(page,size,userid);
        return res;
    }
    @PutMapping("petAllow")
    public boolean petAllow(Adoption adoption){
        return adoptionService.petAllow(adoption);
    }

    @DeleteMapping("delAdo")
    public boolean delAdo(Integer adoid){
        return adoptionService.delAdo(adoid);
    }

    @PutMapping("refuseAdo")
    public RefuseUtil refuseAdo(Integer adoid){
        return adoptionService.refuseAdo(adoid);
    }

}
